package per.sunmes.cl.g.actor.ef;

import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.scenes.scene2d.Actor;

public class BlendDraw extends Actor {

	Actor target;

	public BlendDraw(Actor target) {
		this.target = target;
	}

	public static final int BLEND_SRC = GL20.GL_SRC_ALPHA//
			,
			BLEND_DST = GL20.GL_ONE//
			;

	int oldSrc, oldDst;

	public Actor getTarget() {
		return target;
	}

	public void setTarget(Actor target) {
		this.target = target;
	}

	@Override
	public void draw(Batch batch, float parentAlpha) {
		oldSrc = batch.getBlendSrcFunc();
		oldDst = batch.getBlendDstFunc();
		batch.setBlendFunction(BLEND_SRC, BLEND_DST);
		target.draw(batch, parentAlpha);
		batch.setBlendFunction(oldSrc, oldDst);
	}

}
